﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Core.Model;

namespace EzDesk.Core
{
    public interface ICoreService
    {
        string AppPortalUrl { get; }
        string EzDeskUrl { get; }

        #region [ Users Profile Methods - lastReview: 2010.3.3]
        UserProfile GetUserProfileByUserName(string userName);
        UserProfile GetUserProfileById(Guid userId);
        void ChangeUserDept(Guid userId, Guid deptId);
        void ChangeUserReportId(Guid userId, Guid reportId);
        void ChangeUserPosition(Guid userId, Guid positionId);

        UserProfile CreateEmptyUserProfile(string userName);
        void DeleteUserProfile(Guid userId);

        IList<SimpleUser> GetSimpleUserInfos(Guid[] userIdCollection);
        IList<SimpleUser> GetSimpleUserInfos(string memberstring);
        SimpleUser GetSimpleUserById(Guid userId);

        SimpleUser GetSimpleUserInfoByUserName(string userName);
        IList<SimpleUser> GetUsersInDept(Guid deptId);
        IList<SimpleUser> GetUsersInPosition(Guid posId);
        IList<SimpleUser> GetDirectReports(Guid userId);
        IList<SimpleUser> GetAllReports(Guid userId);
        #endregion [ Users Profile Methods - lastReview: 2010.3.3]

        #region [ Department    -   2010.1.17]
        IList<Dept> GetAllDepts();
        Dept GetDeptById(Guid deptId);
        Dept CreateDept(string deptName);
        void RemoveUserFromCurrentDept(Guid userId);
        void ChangeDeptName(Guid deptId,string deptName);
        void DeleteDept(Guid deptId);
        #endregion [ Department    -   2010.1.17]

        #region [ Group & MemberString    -   2010.1.17]
        Group CreateGroup(SimpleUser[] userIds,Group[] groupIds,string descrition,int type);
        void ChangeGroupDescription(Guid groupId, string description);
        void DeleteGroup(Guid groupId);
        IDictionary<Guid, string> GetChildrenInGroup(Guid groupId);
        IList<SimpleUser> GetAllUsersInGroup(Guid groupId);
        IList<Guid> GetAllUserIdsInGroup(Guid groupId);

        Group GetGroupByDescription(string description);
        Group GetGroupById(Guid groupId);
        Group GetGroupMemberstring(string memberstring);
        IList<Group> GetGroups(string groupIdStrs);
        IList<Group> GetGroups(Guid[] groupIdCollection);

        IList<Group> GetAllSystemGroups();

        void AddUserInGroup(Guid targetGroupId, Guid userId);
        void AddGroupInGroup(Guid targetGroupId, Guid groupId);
        void RemoveUserFromGroup(Guid targetGroupId, Guid userId);
        void RemoveGroupFromGroup(Guid targetGroupId, Guid groupId);

        IList<SimpleUser> GetAllUsersByMemberString(string memberString);
        IList<Guid> GetAllUserIdsByMemberString(string memberString);
        IDictionary<Guid, string> GetChildrenByMemberString(string memberString);
        #endregion [ Group    -   2010.1.17]

        #region [ Position    -   2010.1.17]
        IList<Position> GetPositions();
        Position CreatePosition(string descrition, int priority);
        void ChangePositionPriority(Guid posId,int priority);
        void ChangePositionDescription(Guid posId, string description);
        void DeletePosition(Guid positionId);
        #endregion [ Position    -   2010.1.17]

        #region [ Feed Common    -   2010.3.3 ]

        void SetFeedIsRead(Guid feedId, string memberString, bool isRead);
        void SetFeedIsRead(Guid[] feedIds, string memberString, bool isRead);
        void SetFeedIsRead(string feedIdStrs, string memberString, bool isRead);

        void SetFeedIsAvailable(Guid feedId, string memberString, bool isAvailable);
        void SetFeedIsAvailable(Guid[] feedIds, string memberString, bool isAvailable);
        void SetFeedIsAvailable(string feedIdStrs, string memberString, bool isAvailable);

        void DeleteFeed(Guid feedId, int type);
        void UpdateFeedData(Guid feedId, string newFeedData);
        void UpdateFeedData(Guid[] feedIds, string newFeedData);
        void UpdateFeedData(string feedIdStrs, string newFeedData);

        IList<Feed> GetFeeds(string feedTypeStr, Guid userId, DateTime from, DateTime to, int maxCount, bool? isRead, bool? isAvaiable);
        IList<Feed> GetFeeds(string feedTypeStr, Guid userId, int startIndex, int count, bool? isRead, bool? isAvaiable);

        // 使用templateID发送Feed
        Guid SendFeed(
            string feedTypeStr, /* Feed类型 */
            Guid templateId,  /* 使用的模板ID */
            Guid? senderId,  /* 发送者UserID 可空 */
            string feedData,  /* Feed数据 */
            string memberString, /* 接收者 */
            DateTime expireOn, /* 过期时间 */
            bool sendToSelf /* 这条消息是否发给发送者本人 */);
        // 使用templateName发送Feed
        Guid SendFeed(string feedTypeStr, string templateName, Guid? senderId, string feedData, string memberString, DateTime expireOn, bool sendToSelf);

        void UpdatePersonalFeedData(Guid feedId, string memberstring, string feedDataEx);

        string GetPersonalFeedData(Guid userId, Guid feedId);
        #endregion


        #region [ FeedTemplate    -   2010.3.17]
        FeedTemplate CreateFeedTemplate(Guid appId, string titleTemplate,string bodyTemplate,int type);
        void DeleteFeedTemplate(Guid id);
        FeedTemplate GetFeedTemplateById(Guid templateId);
        IList<FeedTemplate> GetFeedTemplate(string templateName, Guid appId);
        #endregion [ FeedTemplate    -   2010.1.17]

        #region [ App   -   2010.1.24]
        App RegistApp(string appName);
        void DeleteApp(App app);
        IList<App> GetAllApps();
        App GetAppByName(string appName);
        App GetAppById(Guid appId);

        IList<AppTask> GetAllAppTasks(Guid userId, string userAgent);
        IList<AppTask> GetAppTasksByAppName(string appName, Guid userId, string userAgent);
        #endregion [ App   -   2010.1.24]
    }
}
